<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 获取当前日期
    let currentDate = new Date();
    // 获取当前月份
    let currentMonth = currentDate.getMonth();
    // 获取本月之前12个月的月份
    let months = [];
    for (let i = 0; i < 12; i++) {
      let month = currentMonth - i;
      if (month < 0) {
        month += 12;
      }
      months.push(month);
    }
    // 输出结果
    console.log(months);
  </script>
</body>

</html>